package com.backend.mbuser.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.backend.common.annotation.Log;
import com.backend.common.core.controller.BaseController;
import com.backend.common.core.domain.AjaxResult;
import com.backend.common.enums.BusinessType;
import com.backend.mbuser.domain.MobileUser;
import com.backend.mbuser.service.IMobileUserService;
import com.backend.common.utils.poi.ExcelUtil;
import com.backend.common.core.page.TableDataInfo;

/**
 * 移动端用户管理Controller
 * 
 * @author fusi
 * @date 2024-10-12
 */
@RestController
@RequestMapping("/mbuser/mbuser")
public class MobileUserController extends BaseController
{
    @Autowired
    private IMobileUserService mobileUserService;

    /**
     * 查询移动端用户管理列表
     */
    @PreAuthorize("@ss.hasPermi('mbuser:mbuser:list')")
    @GetMapping("/list")
    public TableDataInfo list(MobileUser mobileUser)
    {
        startPage();
        List<MobileUser> list = mobileUserService.selectMobileUserList(mobileUser);
        return getDataTable(list);
    }

    /**
     * 导出移动端用户管理列表
     */
    @PreAuthorize("@ss.hasPermi('mbuser:mbuser:export')")
    @Log(title = "移动端用户管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MobileUser mobileUser)
    {
        List<MobileUser> list = mobileUserService.selectMobileUserList(mobileUser);
        ExcelUtil<MobileUser> util = new ExcelUtil<MobileUser>(MobileUser.class);
        util.exportExcel(response, list, "移动端用户管理数据");
    }

    /**
     * 获取移动端用户管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('mbuser:mbuser:query')")
    @GetMapping(value = "/{mobileUserId}")
    public AjaxResult getInfo(@PathVariable("mobileUserId") Long mobileUserId)
    {
        return success(mobileUserService.selectMobileUserByMobileUserId(mobileUserId));
    }

    /**
     * 新增移动端用户管理
     */
    @PreAuthorize("@ss.hasPermi('mbuser:mbuser:add')")
    @Log(title = "移动端用户管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MobileUser mobileUser)
    {
        return toAjax(mobileUserService.insertMobileUser(mobileUser));
    }

    /**
     * 修改移动端用户管理
     */
    @PreAuthorize("@ss.hasPermi('mbuser:mbuser:edit')")
    @Log(title = "移动端用户管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MobileUser mobileUser)
    {
        return toAjax(mobileUserService.updateMobileUser(mobileUser));
    }

    /**
     * 删除移动端用户管理
     */
    @PreAuthorize("@ss.hasPermi('mbuser:mbuser:remove')")
    @Log(title = "移动端用户管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{mobileUserIds}")
    public AjaxResult remove(@PathVariable Long[] mobileUserIds)
    {
        return toAjax(mobileUserService.deleteMobileUserByMobileUserIds(mobileUserIds));
    }
}
